require("../../../utils/api.js");

var a = require("../../../utils/disapi.js"), t = getApp();

Page({
    data: {
        status: 0,
        list: [],
        nowpage: 1,
        is_last: 0,
        openid: ""
    },
    onLoad: function(e) {
        var o = t.globalData.openid;
        this.setData({
            openid: o
        });
        var s = this;
        wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        }), a.get_dis_cashlog({
            openid: o,
            page: 1
        }).then(function(a) {
            if (0 == a.errno) {
                var t = a.data;
                if (0 == t.code) {
                    var e = t.data, o = 0;
                    e.length < 20 && (o = 1), s.setData({
                        list: e,
                        last: o
                    });
                }
            }
        });
    },
    myTab: function(t) {
        var e = t.currentTarget.dataset.status;
        this.setData({
            status: e
        });
        var o = -2, s = this;
        o = 0 == e ? -2 : 1 == e ? 0 : 3 == e ? 1 : -1, a.get_dis_cashlog({
            openid: this.data.openid,
            page: 1,
            state: o
        }).then(function(a) {
            if (0 == a.errno) {
                var t = a.data;
                if (0 == t.code) {
                    var e = t.data, o = 0;
                    e.length < 20 && (o = 1), s.setData({
                        list: e,
                        last: o,
                        nowpage: 1
                    });
                }
            }
        });
    },
    onReachBottom: function(t) {
        var e = this, o = e.data.nowpage + 1;
        if (console.log(o), console.log(this.data.last), 1 == this.data.last) return !1;
        var s = e.data.status, i = -2;
        i = 0 == s ? -2 : 1 == s ? 0 : 3 == s ? 1 : -1, a.get_dis_cashlog({
            openid: this.data.openid,
            page: o,
            state: i
        }).then(function(a) {
            if (0 == a.errno) {
                var t = a.data;
                if (0 == t.code) {
                    var s = t.data, i = 0;
                    s.length < 20 && (i = 1);
                    var n = e.data.list.concat(s);
                    e.setData({
                        list: n,
                        last: i,
                        nowpage: o
                    });
                }
            }
        });
    }
});